#include "bsp_WS2812.h"
#include "Com_Debug.h"
// LED Strip object handle
led_strip_handle_t led_strip;
void Int_WS2812_Init(void)
{
    // LED strip general initialization, according to your led board design
    led_strip_config_t strip_config = {
        .strip_gpio_num = LED_STRIP_GPIO_PIN,                        // The GPIO that connected to the LED strip's data line
        .max_leds = LED_STRIP_LED_COUNT,                             // The number of LEDs in the strip,
        .led_model = LED_MODEL_WS2812,                               // LED strip model
        .color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRB, // The color order of the strip: GRB
        .flags = {
            .invert_out = false, // don't invert the output signal
        }};

    // LED strip backend configuration: RMT
    led_strip_rmt_config_t rmt_config = {
        .clk_src = RMT_CLK_SRC_DEFAULT,                    // different clock source can lead to different power consumption
        .resolution_hz = LED_STRIP_RMT_RES_HZ,             // RMT counter clock frequency
        .mem_block_symbols = LED_STRIP_MEMORY_BLOCK_WORDS, // the memory block size used by the RMT channel
        .flags = {
            .with_dma = LED_STRIP_USE_DMA, // Using DMA can improve performance when driving more LEDs
        }};

    ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
}
void Int_WS2812_LedOn(void)
{
    led_strip_set_pixel(led_strip, 0, 255, 255, 255);
    led_strip_set_pixel(led_strip, 1, 255, 255, 255);
    led_strip_refresh(led_strip);
}
void Int_WS2812_LedOff(void)
{

    led_strip_clear(led_strip);
    led_strip_refresh(led_strip);
}
void setPower(bool power){
    if (power)
    {
        MY_LOGE("我进来了");
        Int_WS2812_LedOn();
        MY_LOGE("我走了");
    }else if (power == false)
    {
        Int_WS2812_LedOff();
    }
    
    
}